/*
package Work;
import java.util.Arrays;
import java.util.Comparator;
//class Student implements Comparable<Student> {
    private int studentId;
    private String name;
    private int age;
    private double gpa;
    public Student(int studentId, String name, int age, double gpa) {
        this.studentId = studentId;
        this.name = name;
        this.age = age;
        this.gpa = gpa;
    }
    public int getStudentId() { return studentId; }
    public String getName() { return name; }
    public int getAge() { return age; }
    public double getGpa() { return gpa; }
    @Override
    public String toString() {
        return String.format("Student{studentId=%d, name='%s', age=%d, gpa=%.1f}",
                studentId, name, age, gpa);
    }
    @Override
    public int compareTo(Student other) {
        return Integer.compare(this.studentId, other.studentId);
    }
}
class GpaComparator implements Comparator<Student> {
    @Override
    public int compare(Student s1, Student s2) {
        return Double.compare(s2.getGpa(), s1.getGpa());
    }
}
class AgeComparator implements Comparator<Student> {
    @Override
    public int compare(Student s1, Student s2) {
        return Integer.compare(s1.getAge(), s2.getAge());
    }
}
public class Bijiaoqi {
    public static void main(String[] args) {
        Student[] students = {
                new Student(1002, "Bob", 22, 3.5),
                new Student(1001, "Alice", 20, 3.8),
                new Student(1004, "Diana", 19, 3.2),
                new Student(1003, "Charlie", 21, 4.0),
                new Student(1005, "Eve", 23, 3.9)
        };
        System.out.println("=== 学生管理系统排序演示 ===");
        System.out.println("原始数据：");
        printStudents(students);
        System.out.println("\n— 按学号自然排序 —");
        Arrays.sort(students);
        printStudents(students);
        System.out.println("\n— 按 GPA 降序排序 —");
        Arrays.sort(students, new GpaComparator());
        printStudents(students);
        System.out.println("\n— 按年龄升序排序 —");
        Arrays.sort(students, new AgeComparator());
        printStudents(students);
    }
    private static void printStudents(Student[] students) {
        for (Student student : students) {
            System.out.println(student);
        }
    }
}*/
